package com.itheima.mapper;

import com.itheima.pojo.User;
import com.itheima.pojo.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

// 这个接口中的方法都是用来操作user表
public interface UserMapper {
    //查询所有用户
    @Select("select * from user")
    List<User> findAll();

    //修改用户
    @Update("UPDATE user SET username=#{username},birthday=#{birthday},sex=#{sex},address=#{address} WHERE id=#{id}")
    int update(User user);

    //删除用户
    @Delete("DELETE FROM user WHERE id=#{id}")
    int delete(int id);

    //添加用户
    @Insert("INSERT INTO user VALUES (NULL, #{username},#{birthday},#{sex},#{address})")
    void add(User user);
}
